/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package coordinatormonitor;

import Server.Client;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrador
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here

        Thread monitorProcess = new Thread(new Runnable(){

            public void run() {
                System.out.println("Starting monitoring process");
                while(true)
                {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    // hacemos ping
                    Client pingClient = new Client("localhost", 3007);
                    String response = null;
                    try {
                        response = pingClient.sendMessage("PING!");
                    } catch (IOException ex) {
                    }
                    if(response==null) System.out.println("Panic! Coordinator is down.");
                }
            }
        });

        monitorProcess.start();
    }

}
